#!/usr/bin/env python3
"""
检查最新测试结果
"""

import json
from datetime import datetime

def check_results():
    filename = "csv_simulation_results_1760174412.json"
    
    try:
        with open(filename, 'r', encoding='utf-8') as f:
            data = json.load(f)
        
        print(f"总结果数量: {len(data)}")
        
        # 检查错误
        errors = [r for r in data if 'error' in r and r['error']]
        successful = [r for r in data if 'response' in r]
        
        print(f"成功分析: {len(successful)}")
        print(f"错误数量: {len(errors)}")
        
        if data:
            first_timestamp = data[0]['timestamp']
            last_timestamp = data[-1]['timestamp']
            
            first_time = datetime.fromtimestamp(first_timestamp).strftime('%Y-%m-%d %H:%M:%S')
            last_time = datetime.fromtimestamp(last_timestamp).strftime('%Y-%m-%d %H:%M:%S')
            
            print(f"时间范围: {first_time} 到 {last_time}")
            
        if errors:
            print(f"第一个错误: {errors[0]['error']}")
            
        if successful:
            print("\n前3个成功结果:")
            for i, result in enumerate(successful[:3]):
                timestamp_readable = datetime.fromtimestamp(result['timestamp']).strftime('%Y-%m-%d %H:%M:%S')
                response = result['response']
                print(f"{i+1}. 时间: {timestamp_readable}, 睡眠阶段: {response['sleep_stage']}, 置信度: {response['confidence']:.3f}")
        
    except Exception as e:
        print(f"检查结果时出错: {e}")

if __name__ == "__main__":
    check_results()